import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:magic_car/common/global.dart';
import 'package:magic_car/user/login.dart';
import 'package:magic_car/main.dart';
import 'package:shared_preferences/shared_preferences.dart';

class StartPage extends StatefulWidget {
  StartPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<StartPage> {
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: '个人中心',
        debugShowCheckedModeBanner: false,
        home: new Scaffold(
            appBar: new AppBar(
                title: new Text(
                  '车魔估-合伙人',
                  style: TextStyle(color: Colors.black),
                ),
                backgroundColor: Colors.white,
                elevation: 0),
            body:

                //     SingleChildScrollView(
                //       scrollDirection: Axis.vertical,
                // //true 滑动到底部
                // reverse: false,
                // padding: EdgeInsets.all(0.0),
                // physics: BouncingScrollPhysics(),
                // child:
                ConstrainedBox(
                    constraints: BoxConstraints.expand(),
                    child: Stack(
                        alignment: Alignment.center, //指定未定位或部分定位widget的对齐方式
                        children: <Widget>[
                          Positioned(
                            top: 0,
                            left: 0,
                            right: 0,

                            // child:
                            // Center(
                            child: new Container(
                                // color: Color.fromRGBO(255, 204, 48, 1),
                                height: 50,
                                // width: double.infinity,
                                child: Padding(
                                  padding: new EdgeInsets.fromLTRB(0, 20, 0, 0),
                                  child: Center(
                                    child: Text(
                                      '欢迎您',
                                      style: TextStyle(
                                          fontSize: 21,
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  ),
                                )),
                          ),
                          Positioned(
                            top: 50,
                            left: 0,
                            right: 0,

                            // child:
                            // Center(
                            child: new Container(
                                // color: Color.fromRGBO(255, 204, 48, 1),
                                height: 50,
                                // width: double.infinity,
                                child: Padding(
                                  padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                                  child: Center(
                                    child: Text(
                                      '来到车魔估',
                                      style: TextStyle(
                                          fontSize: 21,
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  ),
                                )),
                          ),
                          Positioned(
                            top: 120,
                            left: 0,
                            right: 0,

                            // child:
                            // Center(
                            child: new Container(
                                // color: Color.fromRGBO(255, 204, 48, 1),
                                height: 100,
                                // width: double.infinity,
                                child: Padding(
                                  padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                                  child: Center(
                                      child: new Image.asset(
                                          'resource/images/user/logo2.png')),
                                )),
                          ),
                          Positioned(
                              top: 250,
                              left: 30,
                              right: 30,

                              // child:
                              // Center(
                              child: new Container(
                                // color: Color.fromRGBO(255, 204, 48, 1),
                                height: 50,
                                // width: double.infinity,
                                child: Padding(
                                    padding:
                                        new EdgeInsets.fromLTRB(0, 0, 0, 0),
                                    child: Center(
                                        child: SizedBox(
                                      width: double.infinity,
                                      child: new ClipRRect(
                                        borderRadius: BorderRadius.circular(25),
                                        child: Container(
                                          height: 50,
                                          // color: Color.fromRGBO(27, 182, 251, 1),
                                          child: new RaisedButton(
                                            child: Text('我是合伙人',
                                                style: TextStyle(
                                                  fontSize: 18,
                                                  color: Colors.white,
                                                )),
                                            //color: Colors.red,
                                            onPressed: () {
                                              // Navigator.pushNamed(context, 'blue');
                                              // Navigator.pushNamed(context, 'login');
                                              Navigator.of(context).push(
                                                  new MaterialPageRoute(
                                                      builder: (_) {
                                                return new LoginPage('1');
                                              }));
                                            },
                                            color:
                                                Color.fromRGBO(27, 182, 251, 1),
                                          ),
                                        ),
                                      ),
                                    ))),
                              )),
                          Positioned(
                              top: 330,
                              left: 30,
                              right: 30,

                              // child:
                              // Center(
                              child: new Container(
                                  // color: Color.fromRGBO(255, 204, 48, 1),
                                  height: 50,
                                  // width: double.infinity,
                                  child: Padding(
                                      padding:
                                          new EdgeInsets.fromLTRB(0, 0, 0, 0),
                                      child: Center(
                                          child: SizedBox(
                                              width: double.infinity,
                                              child: new ClipRRect(
                                                  borderRadius:
                                                      BorderRadius.circular(25),
                                                  child: Align(
                                                      alignment:
                                                          Alignment.center,
                                                      child: new Container(
                                                          child: new Material(
                                                              //INK可以实现装饰容器
                                                              child: new Ink(
                                                        //用ink圆角矩形
                                                        // color: Colors.red,
                                                        decoration:
                                                            new BoxDecoration(
                                                          //背景
                                                          color: Colors.white,
                                                          //设置四周圆角 角度
                                                          borderRadius:
                                                              BorderRadius.all(
                                                                  Radius
                                                                      .circular(
                                                                          25.0)),
                                                          //设置四周边框
                                                          border:
                                                              new Border.all(
                                                                  width: 1,
                                                                  color: Color
                                                                      .fromRGBO(
                                                                          27,
                                                                          182,
                                                                          251,
                                                                          1)),
                                                        ),
                                                        child: new InkWell(
                                                            //圆角设置,给水波纹也设置同样的圆角
                                                            //如果这里不设置就会出现矩形的水波纹效果
                                                            borderRadius:
                                                                new BorderRadius
                                                                        .circular(
                                                                    25.0),
                                                            //设置点击事件回调
                                                            onTap: () async {
                                                              SharedPreferences
                                                                  pref =
                                                                  await SharedPreferences
                                                                      .getInstance();
                                                              // pref.setString(
                                                              //     'islogin',
                                                              //     '1');
                                                              pref.setString(
                                                                  'role', "0");
                                                              // Navigator.of(
                                                              //         context)
                                                              //     .pushAndRemoveUntil(
                                                              //         new MaterialPageRoute(
                                                              //             builder: (context) =>
                                                              //                 new MyApp()),
                                                              //         (route) =>
                                                              //             route ==
                                                              //             null);
                                                              Navigator.of(
                                                                      context)
                                                                  .push(new MaterialPageRoute(
                                                                      builder:
                                                                          (_) {
                                                                return new LoginPage(
                                                                    '0');
                                                              }));
                                                            },
                                                            child: Container(
                                                              //设置 child 居中
                                                              alignment:
                                                                  Alignment(
                                                                      0, 0),
                                                              height: 50,
                                                              width: double
                                                                  .infinity,
                                                              child: Text(
                                                                "我是站点",
                                                                style: TextStyle(
                                                                    color: Color
                                                                        .fromRGBO(
                                                                            27,
                                                                            182,
                                                                            251,
                                                                            1),
                                                                    fontSize:
                                                                        18),
                                                              ),
                                                            )),

                                                        // child: new RaisedButton(
                                                        //   child: Text('申请补考'),
                                                        //   onPressed: () {},
                                                        // ),
                                                      )))))))))),
                          Positioned(
                            bottom: 0,
                            left: 0,
                            right: 0,
                            child: Container(
                              height: 60,
                              child: Image.asset(
                                'resource/images/user/back2.png',
                                fit: BoxFit.fill,
                              ),
                            ),
                          )
                        ]))));
  }
}
